#ifndef __RENDER_OBJECT_H__
#define __RENDER_OBJECT_H__

#pragma once

#include "Material.h"
#include "RenderMesh.h"

namespace Nezha
{
	class SceneNode;

	/** hash value for material sorting. */
	struct GRAPHICS_ENTRY RenderQueHashVal
	{
		u16 LayerVal;			// render layer
		u16 PassVal;			//
		u32 MaterialVal;
		u32 ShaderVal;
		u32 StatesVal;
		u32 GeometryVal;
	};

	enum
	{
		MAX_NUM_MATERIAL_LAYERS = 8,
	};

	/** renderable object base. */
	class GRAPHICS_ENTRY RenderObject
	{
	public:
		virtual ~RenderObject(){}

		virtual RenderObjectType getROType() const
		{
			return ROT_NONE;
		}

		virtual const _string& getROName() const = 0;

		virtual SceneNode* getSpatial() = 0;

		u32 getNumMaterialLayers() const
		{
			return mMatLayers.size();
		}

		MaterialPtr getMaterial(u32 i);

		RenderLayer getRenderLayer() const
		{
			return mRenderLayer;
		}

		RenderObjectBatch getBatchType() const
		{
			return mBatchType;
		}

		virtual void setMaterial(u32 i, const MaterialPtr& mat);

		const RenderMesh* getRenderMesh() const
		{
			return mRenderMeshPtr.ptr();
		}

		/** for render pipeline. */
		virtual void prepareGeometry4Pipeline(GeometryDataBatch& batch);

		virtual u32 getGeometryHash();

		RenderObject();

	protected:
		RenderMeshPtr mRenderMeshPtr;
		
		typedef PArray<MaterialPtr> MatLayers;
		MatLayers mMatLayers;

		RenderLayer mRenderLayer;
		RenderObjectBatch mBatchType;
	};

}//end namespace Nezha

#endif //end __RENDER_OBJECT_H__